package com.kbbywyclient.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.kbbywyclient.R;
import com.kbbywyclient.app.Constants;
import com.kbbywyclient.data.entity.MinePartnerDetailsData;
import com.kbbywyclient.ui.adapter.base.BaseAdapter;

import java.util.List;
import java.util.Locale;

/**
 * Created by Jiangzx on 2017/11/3 15:31.
 * 一级、二级、普通合伙人统计明细
 */

public class PartnerDetailsAdapter2 extends BaseAdapter<MinePartnerDetailsData.MonthData>{
    private int role;

    public PartnerDetailsAdapter2(List<MinePartnerDetailsData.MonthData> data, int role) {
        super(data, R.layout.item_partner_details_2);
        this.role=role;
    }

    @Override
    public void convert(Holder holder, MinePartnerDetailsData.MonthData monthData, int position) {
        holder.setText(R.id.tv_date,monthData.getEvery_month());
        holder.setText(R.id.tv_application,String.valueOf(monthData.getInclude_num()));
        holder.setText(R.id.tv_settlement,String.valueOf(monthData.getSettlement_num()));
        TextView tvReward=holder.getView(R.id.tv_reward);
        if(role== Constants.LEVEL_NORMAL){
            tvReward.setVisibility(View.GONE);
        }else{
            String reward=monthData.getUpper_prize_amount();
            if(TextUtils.isEmpty(reward)){
                tvReward.setText("0.00");
            }else{
                tvReward.setText(
                        String.format(Locale.CHINESE,
                                Constants.AMOUNT_FORMAT,
                                Double.parseDouble(reward)));
            }
        }
    }
}
